package com.dragonwu.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * web渲染工具类
 *
 * @author DragonWu
 * @since 2022-10-07 15:36
 **/
public class WebUtil {

    /**
     * @param response   渲染对象
     * @param jsonString 待渲染的字符串
     */
    public static void renderString(HttpServletResponse response, String jsonString) {
        try {
            response.setStatus(200);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().write(jsonString);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
